﻿using System.Windows.Controls;

namespace ProjectWizardManagementv1.Views
{
    /// <summary>
    /// Interaction logic for TasksControl.xaml
    /// </summary>
    public partial class TasksControl : UserControl
    {
        /*
        private TasksControlViewModel _tasks;
        private ObservableCollection<ProjectFileViewModel> _files; 

        public TasksControlViewModel Tasks
        {
            get { return _tasks; }
            set { _tasks = value;
                this.DataContext = value;
            }
        }

        public ObservableCollection<ProjectFileViewModel> Files
        {
            get { return _files; }
            set { _files = value;
                FilesList.ItemsSource = value;
            }
        }*/

        public TasksControl()
        {
            InitializeComponent();
        }

        /*
        private void SaveTask(object sender, RoutedEventArgs e)
        {
            if(TaskName.Text != string.Empty)
            {
                DateTime date;
                var canParseDate = DateTime.TryParse(DueDatePicker.Text, out date);

                var file = FileTaskAssignment.IsEnabled && FilesList.SelectedItem != null
                               ? (FilesList.SelectedItem as ProjectFileViewModel).Path
                               : string.Empty;

                var task = new Task()
                               {
                                   Name = TaskName.Text,
                                   DueDate = canParseDate ? date : DateTime.Now,
                                   IsSendingNotification = IsSendingNotifications.IsEnabled,
                                   FilePath = file,
                                   Description = this.Description.Text
                               };
                Tasks.AddTask(task);
                ClearForm(sender, e);
            }
            else
            {
                MessageBox.Show("Please enter a name for the task.", "Missing Name", MessageBoxButton.OK,
                                MessageBoxImage.Exclamation);
            }
            
        }

        private void ShowTask(object sender, RoutedEventArgs e)
        {
            if(HasSelectedItem())
            {
                var task = TaskListBox.SelectedItem as TaskViewModel;
                Messenger.Default.Send(new NotificationBoxMessage {Header = "To Do: " + task.Name, Message = task.Description});
            }
                
        }
        /*
        private void RemoveTask(object sender, RoutedEventArgs e)
        {
            var selectedTask = TaskListBox.SelectedItem as TaskViewModel;
            TaskViewModels.RemoveTask(selectedTask);
        }

        private void ClearForm(object sender, RoutedEventArgs e)
        {
            TaskName.Text = string.Empty;
            DueDatePicker.Text = string.Empty;
            IsSendingNotifications.IsEnabled = false;
        }

        private bool HasSelectedItem()
        {
            return TaskListBox.SelectedItem != null;
        } */
    }
}
